package T11;

public  class Account {
    public static String bankName;
    private double balance;
    private String accountName;
    private String accountPass;

    // 无参构造方法
    public Account() {
    }

    // 带 3 个参数的构造方法
    public Account(double balance, String accountName, String accountPass) {
        this.balance = balance;
        this.accountName = accountName;
        this.accountPass = accountPass;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getAccountPass() {
        return accountPass;
    }

    public void setAccountPass(String accountPass) {
        this.accountPass = accountPass;
    }

    // 欢迎方法
    public static void welcome() {
        System.out.println(bankName + "欢迎您");
    }

    // 欢送方法
    public static void sayBye() {
        System.out.println("感谢您的使用，欢迎下次光临" + bankName);
    }

    // 存钱方法
    public boolean deposit(String accountName, String accountPass, double money) {
        if (this.accountName.equals(accountName) && this.accountPass.equals(accountPass)) {
            if (money > 0) {
                this.balance += money;
                System.out.println("存入金额: " + money);
                System.out.println("当前账户余额: " + this.balance);
                return true;
            } else {
                System.out.println("输入存款金额错误，请输入大于 0 的金额。");
                return false;
            }
        } else {
            System.out.println("账号或密码不正确，请检查后重新输入。");
            return false;
        }
    }

    // 取钱方法
    public boolean withdraw(String accountName, String accountPass, double money) {
        if (this.accountName.equals(accountName) && this.accountPass.equals(accountPass)) {
            if (money <= this.balance) {
                this.balance -= money;
                System.out.println("取款金额: " + money);
                System.out.println("当前账户余额: " + this.balance);
                return true;
            } else {
                System.out.println("输入取款金额错误，取款金额不能超过账户余额。");
                return false;
            }
        } else {
            System.out.println("账号或密码不正确，请检查后重新输入。");
            return false;
        }
    }
}
 class Test03 {
    public static void main(String[] args) {
        Account.bankName = "招商银行";
        Account.welcome();

        Account account = new Account(1000, "张三", "123456");

        account.deposit("立方公里", "123456", 500);
        account.withdraw("立方公里", "123456", 200);

        Account.sayBye();
    }
}
